home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freaks Macintosh Archive
/
Freaks Macintosh Archive.bin
/
Freaks Macintosh Archives
/
Macintosh
/
Development & Resource Tools
/
MacsBug6.5.3.sit
/
MacsBug 6.5.3
/
Building dcmds
/
C Samples
/
Drvr.c
next >
Wrap
Text File
|
1996-02-22
|
6KB
|
271 lines
/*
File: Drvr.c
Contains: This is the Unit Table dcmd.
Written by: JM3 = Jim Murphy
DAL = Dave Lyons
sad = Scott Douglass
Copyright: © 1988,1993-1996 by Apple Computer, Inc., All Rights Reserved.
Change History (most recent first):
<6> 25-Jan-96 JM3 Updated the sample build commands to be current.
<5> 10/27/95 DAL Draw "-nil-" instead of empty-string for nil DRVR handles
(merged in from Scott Douglass' source).
<4> 10-Dec-94 JM3 Updated for new format 3 dcmd requirements.
<3> 3/14/94 DAL Re-layed-out the columns: removed Window and made room for
everything to be nice on 13" monitors. Made the "that's strange"
message not show up for dRef = 0xFFFE (.Sony for HD-20). Now
Hoon is happy.
<2> 9/14/93 DAL made the driver name column wider
Modification history:
7Dec88 sad show driver version
29Nov88 sad revised for new dcmd names
13Oct88 sad written from file.c
The following MPW commands will build the dcmd and copy it to the "Debugger Prefs" file
in the System folder. The dcmd's name in MacsBug will be the name of the file built by
the Linker.
C Drvr.c
Link -o Drvr -sg Main=STDCLIB,STDIO,SANELIB dcmdGlue.a.o Put.c.o Drvr.c.o" ∂
"{Libraries}Runtime.o"
BuildDcmd Drvr 193 -format3
Echo 'include "Drvr";' | Rez -a -o "{SystemFolder}Debugger Prefs"
*/
#ifdef USESTDIO
#include <stdio.h>
#endif
#include <Types.h>
#include <Memory.h>
#include <Devices.h>
#include <SysEqu.h>
#include "dcmd.h"
#include "put.h"
typedef struct DRVR
{
short drvrFlags;
short drvrDelay;
short drvrEMask;
short drvrMenu;
short drvrOpen;
short drvrPrime;
short drvrCtl;
short drvrStatus;
short drvrClose;
Str255 drvrName;
} DRVR;
static void DrawHdr()
{
// 0 1 2 3 4 5 6 7 8 9
// 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
dcmdDrawLine("\pdRef dNum Driver Flg Ver qHead Storage Dely Drvr at DCE at");
}
#define kColumnNameEnd 37
#define kColumnVersionEnd 46
#define kColumnQHeadEnd 54
#define kColumnStorageEnd 64
#define kColumnDriverAtEnd 78
#define kColumnDCEAtEnd 85
static void DrawDCE(int dref, AuxDCE* dcep)
{
DRVR* drvrp;
PutUHexWord(dref);
PutSpace();
PutUHexWord(~dref);
PutSpace();
if (dcep->dCtlFlags & 0x40)
{
if (dcep->dCtlDriver)
{
drvrp = * (DRVR **) dcep->dCtlDriver;
if (drvrp)
PutPStrTruncTo(drvrp->drvrName, kColumnNameEnd);
else
PutPStrTruncTo("\p-purged-", kColumnNameEnd);
}
else
{
PutPStrTruncTo("\p-nil-", kColumnNameEnd);
};
}
else
{
if (dcep->dCtlDriver)
{
drvrp = (DRVR*)dcep->dCtlDriver;
PutPStrTruncTo(drvrp->drvrName, kColumnNameEnd);
}
else
{
PutPStrTruncTo("\p-nil-", kColumnNameEnd);
};
};
PutSpace();
PutChar((dcep->dCtlFlags & 0x80) ? 'B' : 'b');
PutChar((dcep->dCtlFlags & 0x40) ? 'H' : 'P');
PutChar((dcep->dCtlFlags & 0x20) ? 'O' : 'C');
PutSpace();
PutUDecTo((unsigned char) dcep->dCtlQHdr.qFlags,kColumnVersionEnd); // version
PutSpace();
PutUHexZTo((unsigned long) dcep->dCtlQHdr.qHead,8,kColumnQHeadEnd); // qHead
PutSpace();
PutUHexZTo((unsigned long) dcep->dCtlStorage,8,kColumnStorageEnd); // Storage
PutSpace();
PutUHexWord((unsigned long) dcep->dCtlDelay);
PutSpace();
PutUHexZTo((unsigned long) drvrp,8,kColumnDriverAtEnd);
PutSpace();
PutUHexZTo((unsigned long) dcep,8,kColumnDCEAtEnd);
PutLine();
// For drvr FFFE (.Sony for the HD20, pre-SCSI), it's okay that
// the dCtlRefNum is $FFFB (don't whine about it)
if ( (dref != dcep->dCtlRefNum) && ( ((unsigned short) dref) != (unsigned short) 0xFFFE) )
{
PutPStr("\p that is strange: dCtlRefNum = ");
PutUHexWord(dcep->dCtlRefNum);
PutLine();
}
} // DrawDCE
pascal void CommandEntry(dcmdBlock* paramPtr)
{
static const Str255 usageStr = "\p[refNum|num]";
switch (paramPtr->request)
{
case dcmdInit:
break;
case dcmdHelp:
dcmdDrawLine("\pDisplays driver information for the given refNum or all installed");
dcmdDrawLine("\pdrivers. Flags are B/b=Busy, H/P=Handle/Ptr, O/C=Open/Closed.");
break;
case dcmdGetInfo:
* (long *) &((GetInfoRequestBlockPtr) paramPtr->requestIOBlock)->dcmdVersion = 0x03008000; // version 3.0 final
BlockMoveData(&usageStr, &((GetInfoRequestBlockPtr) paramPtr->requestIOBlock)->usageStr, usageStr[0]+1);
break;
case dcmdDoIt:
{
Boolean doOne = false;
long dref;
int NumDCEs;
dcmdSwapWorlds();
dcmdDrawLine("\pDisplaying Driver Control Entries");
// Get low-memory values after dcmdSwapWorlds().
NumDCEs = *(unsigned short *)UnitNtryCnt;
(void)dcmdGetNextExpression(&dref, &doOne);
if (doOne)
{
int dnum;
dref = (short)dref;
if (dref < 0)
dnum = ~dref;
else
{
dnum = dref;
dref = ~dref;
}
if (dnum > NumDCEs)
{
#ifdef USESTDIO
Str255 line;
sprintf(line,"Bad refnum 0x%.4x",(unsigned short)dref);
dcmdDrawLine((Str255)c2pstr(&line));
#else
PutPStr("\pBad refnum ");
PutUHexWord(dref);
PutSpace();
PutUHexWord(~dref);
PutLine();
#endif
}
else
{
AuxDCE** dceh = (*(AuxDCE****)UTableBase)[dnum];
if (dceh)
{
DrawHdr();
DrawDCE(dref,*dceh);
}
else
{
PutPStr("\pDriver ");
PutUHexWord(dref);
PutSpace();
PutUHexWord(~dref);
PutPStr("\p is not in installed");
PutLine();
}
}
}
else
{
int DCEsUsed = 0;
int dnum;
AuxDCE*** dcehp;
Boolean foundOne = false;
for(dnum = 0, dcehp = *(AuxDCE****)UTableBase; dnum < NumDCEs; dnum++, dcehp++)
{
if (*dcehp)
{
DCEsUsed++;
if (!foundOne)
{
DrawHdr();
foundOne = true;
}
DrawDCE(~dnum,**dcehp);
}
if (paramPtr->aborted) break;
}
if(!paramPtr->aborted)
{
PutUDec(NumDCEs);
PutPStr("\p Unit Table entries, ");
PutUDec(DCEsUsed);
PutPStr("\p in use, ");
PutUDec(NumDCEs - DCEsUsed);
PutPStr("\p free");
PutLine();
}
}
dcmdSwapWorlds();
break;
}
// Version 3 and newer dcmds must quietly ignore requests we don't recognize.
default:
break;
}
}